package com.tanhua.dubbo.api;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.tanhua.dubbo.mappers.ExamMapper;
import com.tanhua.dubbo.mappers.QuestionsMapper;
import com.tanhua.model.domain.Questions;
import org.apache.dubbo.config.annotation.DubboService;
import org.springframework.beans.factory.annotation.Autowired;

import java.util.List;

import static sun.security.krb5.Confounder.intValue;

@DubboService
public class QuestionsApiImpl implements QuestionsApi{
    @Autowired
    private QuestionsMapper questionsMapper;

    @Override
    public List<Questions> findByExamId(Long examId) {
        LambdaQueryWrapper<Questions> lqw = new LambdaQueryWrapper<>();
        lqw.eq(examId!=null,Questions::getExamId,examId);
        return questionsMapper.selectList(lqw);
    }

    @Override
    public int findLevelById(String questionId) {
        LambdaQueryWrapper<Questions> lqw = new LambdaQueryWrapper<>();
        lqw.eq(Questions::getId,questionId);

        int examId = Integer.valueOf(questionsMapper.selectOne(lqw).getExamId()) ;

        return examId;
    }
}
